package jman.teemwork07;

public class Servise {
	private User login_User=new User();
	public User getLogin_User() {
		return login_User;
	}
	public void setLogin_User(User login_User) {
		this.login_User = login_User;
	}
	public boolean detectId(String id){
		User user=new User();
		if(UsersMap.usersMap.containsKey(id)){
			System.out.println("该用户名已被注册");
			return false;
		}else{
			return true;
		}
	}
	public void registered(String id,String passWord){
		User user=new User();
		user.setId(id);
		user.setPassWord(passWord);
		UsersMap.usersMap.put(user.getId(), user);
		System.out.println("注册成功");
	}
	public boolean detectPassWord(String id,String passWord){
		if(UsersMap.usersMap.containsKey(id)){
			if(passWord.equals(UsersMap.usersMap.get(id).getPassWord())){
				return true;
			}else{
				return false;
			}
		}else{
			return false;
		}
	}
	public void login(String id,String passWord){
		if(detectPassWord(id,passWord)){
			System.out.println("登陆成功");
			setLogin_User(UsersMap.usersMap.get(id));
		}else{
			System.out.println("用户或密码输入错误");
		}
	}
	public void setAge(int age) {
		login_User.setAge(age);
		System.out.println("修改年龄成功");
	}
	public void setSex(String sex) {
		login_User.setSex(sex);
		System.out.println("修改性别成功");
	}
}
